package kassiopeia.gui

import org.apache.log4j.Logger;
import org.apache.activemq.command.ActiveMQObjectMessage;
import kassiopeia.commons.io.TaskMessage;
import kassiopeia.commons.model.task.TaskDescriptor;
import kassiopeia.commons.model.xml.TaskDescriptorXmlSerializer;

class TaskSenderService {

    static transactional = true

    private static final Logger log = Logger.getLogger(TaskSenderService.class)

    MessageSenderService messageSenderService

    def sendTask(TaskDescriptor task, List agentsIds) {
        log.info('Sending task: ' + TaskDescriptorXmlSerializer.toXml(task) + ' to: ' + agentsIds)
        TaskMessage message = new TaskMessage(task)
        agentsIds.each {
            messageSenderService.send(message, it)
        }
    }
}
